#include "Person.h"

void Person_Destroy(Person* self){
    free(self);
}

const char* Person_ToString(Person* self){
    char* retStr = malloc(50);
    snprintf(retStr, 50, "Person: %s, age is %d\n", self->name, self->age);
    return retStr;
}

const char* Person_GetType(Person* self){
    return "Person";
}

static ObjectVTable Persion_VTable = {
    (void (*)(Object* ))Person_Destroy,
    (const char * (*) (Object *))Person_ToString,
    (const char * (*) (Object *))Person_GetType
};

Person* Person_Create(const char * name, int age){
    Person* person = malloc(sizeof(Person));
    person->name = strdup(name);
    person->age = age;

    person->base.vtbl = &Persion_VTable;
    return person;
}